#include <iostream>
#include <cstdlib>

#define vanmezo(x,y) (x>=0 && x<xmeret && y>=0 && y<ymeret)

using namespace std;

int ymeret;
int xmeret;

int diff(int x, int y) {
	int dx,dy;
	dx = abs((xmeret / 2)-x);
	dy = abs((ymeret / 2)-y);
	return ((dx > dy) ? dx : dy);
}

int pontszam(int c, int lezarva, int tamad) {
	// ketoldalrol lezart = fagyi
	if (lezarva == 2 && c != 4) return -10;
	// vedo lepesek
	if (tamad == 0) switch (c) {
		case 0: if (lezarva) return 1; else return 2;
			break;
		case 1: if (lezarva) return 5; else return 6;
			break;
		case 2: if (lezarva) return 9; else return 10;
			break;
		case 3: if (lezarva) return 13; else return 14;
			break;
		default: if (lezarva) return 17; else return 18;
			break;
	}
	// tamado lepesek
	else switch (c) {
		case 0: if (lezarva) return 3; else return 4;
			break;
		case 1: if (lezarva) return 7; else return 8;
			break;
		case 2: if (lezarva) return 11; else return 12;
			break;
		case 3: if (lezarva) return 15; else return 16;
			break;
		default: if (lezarva) return 19; else return 20;
			break;
	}
}

int main(int argc, char** argv) {

    char mi;
    
    cin >> ymeret;
    cin >> xmeret;
    cin >> mi;
    
    char tabla[xmeret][ymeret];
    
    for (int y = 0; y < ymeret; y++) {
        for (int x = 0; x < xmeret; x++) {
            cin >> tabla[x][y];
        }
    }

	char ok,t,tok,tmi;
	int p,x,y,i,c,lezarva,max,bx,by,tamado;
	int ptabla[xmeret][ymeret];

	/* ponttabla inicializalasa DEFAULT = -100 */
	for (y=0; y<ymeret; y++)
		for (x=0; x<xmeret; x++) ptabla[x][y] = -100;

	ok = (mi == 'X') ? 'O' : 'X';

	tok = ok;
	tmi = mi;

	// vizszintes
	for (y=0; y<ymeret; y++) for (x=0; x<xmeret; x++)
	if (tabla[x][y] == '.') {

		for (tamado = 1; tamado>=0; tamado--) {
			max = 0;
			if (tamado == 0) {
				t = tok;
				tok = tmi;
				tmi = t;
			}
			
			// vizszintes
			p = 0; c = 0; lezarva = 0; i = 1;
			while (vanmezo(x+i,y) && tabla[x+i][y] == tmi) { c++; i++; }
			if (tabla[x+i][y] == tok) lezarva++;
			i = 1;
			while (vanmezo(x-i,y) && tabla[x-i][y] == tmi) { c++; i++; }
			if (tabla[x-i][y] == tok) lezarva++;
			p = pontszam(c,lezarva,tamado);
			max = p > max ? p : max;
			
			// fuggoleges
			p = 0; c = 0; lezarva = 0; i = 1;
			while (vanmezo(x,y+i) && tabla[x][y+i] == tmi) { c++; i++; }
			if (tabla[x][y+i] == tok) lezarva++;
			i = 1;
			while (vanmezo(x,y-i) && tabla[x][y-i] == tmi) { c++; i++; }
			if (tabla[x][y-i] == tok) lezarva++;
			p = pontszam(c,lezarva,tamado);
			max = p > max ? p : max;
			
			// foatlo
			p = 0; c = 0; lezarva = 0; i = 1;
			while (vanmezo(x+i,y+i) && tabla[x+i][y+i] == tmi) { c++; i++; }
			if (tabla[x+i][y+i] == tok) lezarva++;
			i = 1;
			while (vanmezo(x-i,y-i) && tabla[x-i][y-i] == tmi) { c++; i++; }
			if (tabla[x-i][y-i] == tok) lezarva++;
			p = pontszam(c,lezarva,tamado);
			max = p > max ? p : max;
			
			// mellekatlo
			p = 0; c = 0; lezarva = 0; i = 1;
			while (vanmezo(x+i,y-i) && tabla[x+i][y-i] == tmi) { c++; i++; }
			if (tabla[x+i][y-i] == tok) lezarva++;
			i = 1;
			while (vanmezo(x-i,y+i) && tabla[x-i][y+i] == tmi) { c++; i++; }
			if (tabla[x-i][y+i] == tok) lezarva++;
			p = pontszam(c,lezarva,tamado);
			max = p > max ? p : max;
			
			ptabla[x][y] = max;
		}
	}

	bx = 0;
	by = 0;
	for (y=0; y<ymeret; y++) for (x=0; x<xmeret; x++) {
		if (ptabla[x][y] > ptabla[bx][by] || (ptabla[x][y] == ptabla[bx][by] && diff(x,y) < diff(bx,by))) {
			bx = x;
			by = y;
		}
	}
	
	cout << bx << " " << by << " score: " << ptabla[bx][by] << endl;
	
	return 0;

}
